/** 鼠标跟随提示文字Dom */
export default class TipDOM {
    constructor(viewer, domId) {
        this.viewer = viewer;
        this.dom = this.creatTipDom(domId);
    }
    // 生成提示DOM
    creatTipDom(domId) {
        const tipDom = document.createElement('div');
        if (domId) tipDom.id = domId;
        tipDom.className = 'backdrop';
        tipDom.style.display = 'none';
        tipDom.style.position = 'absolute';
        tipDom.style.top = '0';
        tipDom.style.left = '0';
        tipDom.style['pointer-events'] = 'none';
        tipDom.style.padding = '4px';
        tipDom.style.backgroundColor = 'black';
        tipDom.style.color = 'white';
        this.viewer.container.appendChild(tipDom);
        return tipDom;
    }
    // 动态计算并改变tipDOM位置
    moveTipDOMPosition(x, y) {
        const box = this.viewer.canvas.getBoundingClientRect();
        this.dom.style.top = box.y + y + 'px';
        this.dom.style.left = box.x + x + 'px';
    }
    show(text = '') {
        this.dom.style.display = 'block';
        this.dom.innerText = text;
        document.body.style.cursor = 'crosshair';
    }
    changeText(text = '') {
        this.dom.innerText = text;
    }
    close() {
        this.dom.style.display = 'none';
        document.body.style.cursor = 'default';
    }
}
